function ShowSnsBar() {
  var bar = $('#sns-share-bar');
  bar.html('<span style="float:left;color:#448;font-weight:normal;font-size:11px;line-height:18px;">分享到 : </span> <a id="renren-share" class="sns-share" title="人人网" href="#nogo"></a>'
    + '<a id="douban-share" class="sns-share" title="豆瓣" href="#nogo" ></a>'
    + '<a id="sina-t-share" class="sns-share" title="新浪微博" href="#nogo" ></a>'
    + '<a id="qq-t-share" class="sns-share" title="腾讯微博" href="#nogo" ></a>');
    
  var esc = encodeURIComponent;
  function GetWinParas(width, height) {
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2 - 10;
    return 'toolbar=0,resizable=1,scrollbars=yes,status=0,width=' 
      + width + ',height=' + height + ',top=' + top + ',left=' + left;
  }

  function Report(postfix) {
    $(document.body).append($('<img src="http://static.slowrose.com/stat/' + postfix + '"/>'));
  }

  $('#renren-share', bar).click(
    function() {
      var url = 'http://share.renren.com/share/buttonshare.do?link=' 
          + esc(location.href) + '&title=' + esc(document.title);
      window.open(url, 'renren', GetWinParas(606, 356));
      Report('share.png?aid=' + article_id + '&share=renren');
    }
  );
  $('#douban-share', bar).click(
    function() {
      var url = 'http://www.douban.com/recommend/?url=' + esc(location.href) + '&title=' + esc(document.title);
      window.open(url, 'douban', GetWinParas(470, 360));
      Report('share.png?aid=' + article_id + '&share=douban');
    }
  );

  $('#sina-t-share', bar).click(
    function() {
      var url = 'http://v.t.sina.com.cn/share/share.php?appkey=2566392091&url='
          + esc(location.href) + '&title=' + esc(document.title) + '&source=' + esc('SlowRose价值投资博客')
          + '&sourceUrl=' + esc('http://www.slowrose.com/') + '&content=utf-8&pic=';
      window.open(url, 'sina-t', GetWinParas(440, 430));
      Report('share.png?aid=' + article_id + '&share=sina-t');
    }
  );

  $('#qq-t-share', bar).click(
    function() {  
      var url = 'http://v.t.qq.com/share/share.php?title='+ esc(document.title)
        + '&url=' + esc(document.location) + '&site=' + esc('http://www.slowrose.com') + '&pic=';
      window.open(url, 'qq-t', GetWinParas(680, 480));
      Report('share.png?aid=' + article_id + '&share=qq-t');
    }
  );
}

Date.prototype.pattern=function(fmt) {           
    var o = {           
    "M+" : this.getMonth()+1, //月份           
    "d+" : this.getDate(), //日           
    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时           
    "H+" : this.getHours(), //小时           
    "m+" : this.getMinutes(), //分           
    "s+" : this.getSeconds(), //秒           
    "q+" : Math.floor((this.getMonth()+3)/3), //季度           
    "S" : this.getMilliseconds() //毫秒           
    };           
    var week = {           
    "0" : "/u65e5",           
    "1" : "/u4e00",           
    "2" : "/u4e8c",           
    "3" : "/u4e09",           
    "4" : "/u56db",           
    "5" : "/u4e94",           
    "6" : "/u516d"          
    };           
    if(/(y+)/.test(fmt)){           
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));           
    }           
    if(/(E+)/.test(fmt)){           
        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "/u661f/u671f" : "/u5468") : "")+week[this.getDay()+""]);           
    }           
    for(var k in o){           
        if(new RegExp("("+ k +")").test(fmt)){           
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));           
        }           
    }           
    return fmt;           
}         
       
// var date = new Date();        
// window.alert(date.pattern("yyyy-MM-dd hh:mm:ss"));  

function escapeHTML(str) {  
  str = String(str).replace(/&/g, '&amp;').  
    replace(/>/g, '&gt;').  
    replace(/</g, '&lt;').  
    replace(/"/g, '&quot;');  
    return str;  
}  
function unescapeHTML(str) {  
  str = String(str).replace(/&gt;/g, '>').  
    replace(/&lt;/g, '<').  
    replace(/&quot;/g, '"').  
    replace(/&amp;/g, '&');  
  return str;  
}  

$(document).ready(
  function() {
    ShowSnsBar();
  }
);
